<html>
    <script>
        let token = localStorage.getItem("token");
        if (token) {
            // 重定向至初始地址 original
            let originalUrl = getQueryVariable("original")
            originalUrl = originalUrl + "?loginState=true&token="+token
            window.location.replace(originalUrl);
        } else {
            // 重定向至初始地址 original
            let originalUrl = getQueryVariable("original")
            originalUrl = originalUrl + "?loginState=false"
            window.location.replace(originalUrl);
        }

        function getQueryVariable(variable)
        {
            const query = window.location.search.substring(1);
            const vars = query.split("&");
            for (let i=0; i<vars.length; i++) {
                const pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
            }
            return(false);
        }
    </script>
</html>